<?php

/**
 * Created by PhpStorm
 * User: 林振宇
 * Date: 2020/8/14
 * Time: 10:56
 */

namespace app\api\controller;

use app\api\library\WeChat\Payment;
use app\api\service\OrderService;
use app\api\service\TokenService;

class Order extends Base
{

    private $user_info; //当前访问用户

    public function __construct()
    {
        $this->user_info = (new TokenService())->checkToken();
    }

    //购票
    public function tickets()
    {
        $data = (new OrderService())->tickets($this->user_info['id'], $this->user_info['openid']);
        $order = (new Payment())->order($data);
        $this->success('购买成功', $order);
    }

    // yunzhihui 修改预约使用时间
    public function reserve()
    {
        $res = (new OrderService())->reserve($this->user_info['id']);
        $this->success('修改成功', $res);
    }

    //扫码核销
    public function cancellation()
    {
        return (new OrderService())->cancellation($this->user_info['id']);
    }

    //按人数核销
    public function apply()
    {
        return (new OrderService())->apply($this->user_info['id']);
    }

    //订单列表
    public function orderList()
    {
        $data = (new OrderService())->orderList($this->user_info['id']);
        $this->success('success', $data);
    }


    //二维码展示
    public function qrCode()
    {
        $data = (new OrderService())->qrCode();
        $this->success('success', $data);
    }

    //取消订单
    public function deposit()
    {
        return (new OrderService())->deposit($this->user_info['id']);
    }

    //订单详情
    public function orderDetails()
    {
        $res = (new OrderService())->orderDetails($this->user_info['id']);
        $this->success('success', $res);
    }

}
